package com.burstly.lib.persistance;

import android.content.Context;
import com.burstly.lib.util.LoggerExt;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;

public class ObjectSaveLoadHandler<T extends Serializable>
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = ObjectSaveLoadHandler.class.getSimpleName();
  private final Context mContext;
  private String mFileName;

  public ObjectSaveLoadHandler(Context paramContext, String paramString)
  {
    this.mContext = paramContext.getApplicationContext();
    this.mFileName = paramString;
  }

  private InputStream openFileReadStream()
  {
    try
    {
      FileInputStream localFileInputStream = this.mContext.openFileInput(this.mFileName);
      return localFileInputStream;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      LOG.logInfo(TAG, "Could not obtain file to read last response!", new Object[0]);
    }
    return null;
  }

  private OutputStream openFileWriteStream()
  {
    try
    {
      FileOutputStream localFileOutputStream = this.mContext.openFileOutput(this.mFileName, 0);
      return localFileOutputStream;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
      LoggerExt localLoggerExt = LOG;
      String str = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mFileName;
      localLoggerExt.logWarning(str, "Could not save file {0}!", arrayOfObject);
    }
    return null;
  }

  public void delete()
  {
    if (!this.mContext.deleteFile(this.mFileName))
    {
      LoggerExt localLoggerExt2 = LOG;
      String str2 = TAG;
      Object[] arrayOfObject2 = new Object[1];
      arrayOfObject2[0] = this.mFileName;
      localLoggerExt2.logWarning(str2, "{0} file could not be deleted!", arrayOfObject2);
      return;
    }
    LoggerExt localLoggerExt1 = LOG;
    String str1 = TAG;
    Object[] arrayOfObject1 = new Object[1];
    arrayOfObject1[0] = this.mFileName;
    localLoggerExt1.logWarning(str1, "{0} file was deleted.", arrayOfObject1);
  }

  public String getFileName()
  {
    return this.mFileName;
  }

  // ERROR //
  public T load()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 89	com/burstly/lib/persistance/ObjectSaveLoadHandler:openFileReadStream	()Ljava/io/InputStream;
    //   4: astore_1
    //   5: aconst_null
    //   6: astore_2
    //   7: aload_1
    //   8: ifnull +99 -> 107
    //   11: new 91	java/io/ObjectInputStream
    //   14: dup
    //   15: aload_1
    //   16: invokespecial 94	java/io/ObjectInputStream:<init>	(Ljava/io/InputStream;)V
    //   19: astore_3
    //   20: aload_3
    //   21: invokevirtual 98	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   24: astore 9
    //   26: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   29: astore 10
    //   31: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   34: astore 11
    //   36: iconst_1
    //   37: anewarray 5	java/lang/Object
    //   40: astore 12
    //   42: aload 12
    //   44: iconst_0
    //   45: aload 9
    //   47: invokestatic 104	com/burstly/lib/util/Utils:toJson	(Ljava/lang/Object;)Ljava/lang/String;
    //   50: aastore
    //   51: aload 10
    //   53: aload 11
    //   55: ldc 106
    //   57: aload 12
    //   59: invokevirtual 109	com/burstly/lib/util/LoggerExt:logDebug	(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   62: pop
    //   63: aload 9
    //   65: checkcast 111	java/io/Serializable
    //   68: astore 14
    //   70: aload_3
    //   71: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   74: aload_1
    //   75: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   78: aload 14
    //   80: areturn
    //   81: astore 15
    //   83: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   86: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   89: ldc 117
    //   91: iconst_0
    //   92: anewarray 5	java/lang/Object
    //   95: invokevirtual 69	com/burstly/lib/util/LoggerExt:logWarning	(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   98: pop
    //   99: aload_2
    //   100: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   103: aload_1
    //   104: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   107: aconst_null
    //   108: areturn
    //   109: astore 7
    //   111: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   114: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   117: aload 7
    //   119: invokevirtual 121	com/burstly/lib/util/LoggerExt:logThrowable	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   122: aload_2
    //   123: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   126: aload_1
    //   127: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   130: goto -23 -> 107
    //   133: astore 8
    //   135: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   138: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   141: aload 8
    //   143: invokevirtual 121	com/burstly/lib/util/LoggerExt:logThrowable	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   146: aload_2
    //   147: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   150: aload_1
    //   151: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   154: goto -47 -> 107
    //   157: astore 5
    //   159: aload_2
    //   160: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   163: aload_1
    //   164: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   167: aload 5
    //   169: athrow
    //   170: astore 5
    //   172: aload_3
    //   173: astore_2
    //   174: goto -15 -> 159
    //   177: astore 8
    //   179: aload_3
    //   180: astore_2
    //   181: goto -46 -> 135
    //   184: astore 7
    //   186: aload_3
    //   187: astore_2
    //   188: goto -77 -> 111
    //   191: astore 4
    //   193: aload_3
    //   194: astore_2
    //   195: goto -112 -> 83
    //
    // Exception table:
    //   from	to	target	type
    //   11	20	81	java/io/IOException
    //   11	20	109	java/lang/ClassNotFoundException
    //   11	20	133	java/lang/Throwable
    //   11	20	157	finally
    //   83	99	157	finally
    //   111	122	157	finally
    //   135	146	157	finally
    //   20	70	170	finally
    //   20	70	177	java/lang/Throwable
    //   20	70	184	java/lang/ClassNotFoundException
    //   20	70	191	java/io/IOException
  }

  // ERROR //
  public void save(T paramT)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnull +75 -> 76
    //   4: aload_0
    //   5: invokespecial 125	com/burstly/lib/persistance/ObjectSaveLoadHandler:openFileWriteStream	()Ljava/io/OutputStream;
    //   8: astore_2
    //   9: aconst_null
    //   10: astore_3
    //   11: aload_2
    //   12: ifnull +64 -> 76
    //   15: new 127	java/io/ObjectOutputStream
    //   18: dup
    //   19: aload_2
    //   20: invokespecial 130	java/io/ObjectOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   23: astore 4
    //   25: aload 4
    //   27: aload_1
    //   28: invokevirtual 134	java/io/ObjectOutputStream:writeObject	(Ljava/lang/Object;)V
    //   31: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   34: astore 9
    //   36: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   39: astore 10
    //   41: iconst_1
    //   42: anewarray 5	java/lang/Object
    //   45: astore 11
    //   47: aload 11
    //   49: iconst_0
    //   50: aload_1
    //   51: invokestatic 104	com/burstly/lib/util/Utils:toJson	(Ljava/lang/Object;)Ljava/lang/String;
    //   54: aastore
    //   55: aload 9
    //   57: aload 10
    //   59: ldc 136
    //   61: aload 11
    //   63: invokevirtual 109	com/burstly/lib/util/LoggerExt:logDebug	(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   66: pop
    //   67: aload_2
    //   68: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   71: aload 4
    //   73: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   76: return
    //   77: astore 13
    //   79: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   82: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   85: ldc 138
    //   87: iconst_0
    //   88: anewarray 5	java/lang/Object
    //   91: invokevirtual 141	com/burstly/lib/util/LoggerExt:logError	(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   94: pop
    //   95: aload_2
    //   96: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   99: aload_3
    //   100: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   103: return
    //   104: astore 8
    //   106: getstatic 30	com/burstly/lib/persistance/ObjectSaveLoadHandler:LOG	Lcom/burstly/lib/util/LoggerExt;
    //   109: getstatic 22	com/burstly/lib/persistance/ObjectSaveLoadHandler:TAG	Ljava/lang/String;
    //   112: aload 8
    //   114: invokevirtual 121	com/burstly/lib/util/LoggerExt:logThrowable	(Ljava/lang/String;Ljava/lang/Throwable;)V
    //   117: aload_2
    //   118: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   121: aload_3
    //   122: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   125: return
    //   126: astore 6
    //   128: aload_2
    //   129: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   132: aload_3
    //   133: invokestatic 115	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   136: aload 6
    //   138: athrow
    //   139: astore 6
    //   141: aload 4
    //   143: astore_3
    //   144: goto -16 -> 128
    //   147: astore 8
    //   149: aload 4
    //   151: astore_3
    //   152: goto -46 -> 106
    //   155: astore 5
    //   157: aload 4
    //   159: astore_3
    //   160: goto -81 -> 79
    //
    // Exception table:
    //   from	to	target	type
    //   15	25	77	java/io/IOException
    //   15	25	104	java/lang/Throwable
    //   15	25	126	finally
    //   79	95	126	finally
    //   106	117	126	finally
    //   25	67	139	finally
    //   25	67	147	java/lang/Throwable
    //   25	67	155	java/io/IOException
  }

  public void setFileName(String paramString)
  {
    this.mFileName = paramString;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.persistance.ObjectSaveLoadHandler
 * JD-Core Version:    0.6.2
 */